home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kopenssl.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-07-22  |  18.6 KB  |  904 lines

  1. /* This file is part of the KDE libraries
  2.    Copyright (C) 2001-2003 George Staikos <staikos@kde.org>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License version 2 as published by the Free Software Foundation.
  7.  
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU Library General Public License
  14.    along with this library; see the file COPYING.LIB.  If not, write to
  15.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16.    Boston, MA 02110-1301, USA.
  17. */
  18.  
  19.  
  20. // IF YOU ARE USING THIS CLASS, YOU ARE MAKING A MISTAKE.
  21.  
  22. #ifndef __KOPENSSLPROXY_H 
  23. #define __KOPENSSLPROXY_H
  24.  
  25. #define KOSSL KOpenSSLProxy
  26. class KOpenSSLProxyPrivate;
  27.  
  28. #include <klibloader.h>
  29.  
  30. #ifdef Q_WS_WIN
  31. #include "ksslconfig_win.h"
  32. #else
  33. #include "ksslconfig.h"
  34. #endif
  35.  
  36. #ifdef KSSL_HAVE_SSL
  37. #define crypt _openssl_crypt
  38. #include <openssl/ssl.h>
  39. #include <openssl/x509.h>
  40. #include <openssl/x509v3.h>
  41. #include <openssl/pem.h>
  42. #include <openssl/bio.h>
  43. #include <openssl/rand.h>
  44. #include <openssl/asn1.h>
  45. #include <openssl/pkcs7.h>
  46. #include <openssl/pkcs12.h>
  47. #include <openssl/evp.h>
  48. #include <openssl/stack.h>
  49. #include <openssl/bn.h>
  50. #undef crypt
  51. #endif
  52.  
  53. #include <kstaticdeleter.h>
  54.  
  55. /**
  56.  * Dynamically load and wrap OpenSSL.
  57.  *
  58.  * @author George Staikos <staikos@kde.org>
  59.  * @see KSSL
  60.  * @short KDE OpenSSL Wrapper
  61.  * @internal
  62.  */
  63. class KIO_EXPORT KOpenSSLProxy {
  64. friend class KStaticDeleter<KOpenSSLProxy>;
  65. public:
  66.  
  67.    /**
  68.     * Return an instance of class KOpenSSLProxy *
  69.     * You cannot delete this object.  It is a singleton class.
  70.     */
  71.    static KOpenSSLProxy *self();
  72.  
  73.    /**
  74.     *   Return true of libcrypto was found and loaded
  75.     */
  76.    bool hasLibCrypto() const;
  77.  
  78.    /**
  79.     *   Return true of libssl was found and loaded
  80.     */
  81.    bool hasLibSSL() const;
  82.  
  83.    /**
  84.     *   Destroy the class and start over - don't use this unless you know
  85.     *   what you are doing.
  86.     */
  87.    void destroy();
  88.  
  89.    // Here are the symbols that we need.
  90. #ifdef KSSL_HAVE_SSL
  91.  
  92.    /*
  93.     *   SSL_connect - initiate the TLS/SSL handshake with an TLS/SSL server
  94.     */
  95.    int SSL_connect(SSL *ssl);
  96.  
  97.    /*
  98.     *   SSL_accept - initiate the TLS/SSL handshake with an TLS/SSL server
  99.     */
  100.    int SSL_accept(SSL *ssl);
  101.  
  102.    /*
  103.     *   SSL_get_error - get the error code
  104.     */
  105.    int SSL_get_error(SSL *ssl, int rc);
  106.  
  107.    /*
  108.     *   SSL_read - read bytes from a TLS/SSL connection.
  109.     */
  110.    int SSL_read(SSL *ssl, void *buf, int num);
  111.  
  112.    /*
  113.     *   SSL_write - write bytes to a TLS/SSL connection.
  114.     */
  115.    int SSL_write(SSL *ssl, const void *buf, int num);
  116.  
  117.    /*
  118.     *   SSL_new - create a new SSL structure for a connection
  119.     */
  120.    SSL *SSL_new(SSL_CTX *ctx);
  121.  
  122.    /*
  123.     *   SSL_free - free an allocated SSL structure
  124.     */
  125.    void SSL_free(SSL *ssl);
  126.  
  127.    /*
  128.     *   SSL_shutdown - shutdown an allocated SSL connection
  129.     */
  130.    int SSL_shutdown(SSL *ssl);
  131.  
  132.    /*
  133.     *   SSL_CTX_new - create a new SSL_CTX object as framework for TLS/SSL enabled functions
  134.     */
  135.    SSL_CTX *SSL_CTX_new(SSL_METHOD *method);
  136.  
  137.    /*
  138.     *   SSL_CTX_free - free an allocated SSL_CTX object
  139.     */
  140.    void SSL_CTX_free(SSL_CTX *ctx);
  141.  
  142.    /*
  143.     *   SSL_set_fd - connect the SSL object with a file descriptor
  144.     */
  145.    int SSL_set_fd(SSL *ssl, int fd);
  146.  
  147.    /*
  148.     *   SSL_pending - obtain number of readable bytes buffered in an SSL object
  149.     */
  150.    int SSL_pending(SSL *ssl);
  151.  
  152.    /*
  153.     *   SSL_peek - obtain bytes buffered in an SSL object
  154.     */
  155.    int SSL_peek(SSL *ssl, void *buf, int num);
  156.  
  157.    /*
  158.     *   SSL_CTX_set_cipher_list - choose list of available SSL_CIPHERs
  159.     */
  160.    int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str);
  161.  
  162.    /*
  163.     *   SSL_CTX_set_verify - set peer certificate verification parameters
  164.     */
  165.    void SSL_CTX_set_verify(SSL_CTX *ctx, int mode,
  166.                          int (*verify_callback)(int, X509_STORE_CTX *));
  167.  
  168.    /*
  169.     *   SSL_use_certificate - load certificate
  170.     */
  171.    int SSL_use_certificate(SSL *ssl, X509 *x);
  172.  
  173.    /*
  174.     *   SSL_get_current_cipher - get SSL_CIPHER of a connection
  175.     */
  176.    SSL_CIPHER *SSL_get_current_cipher(SSL *ssl);
  177.  
  178.    /*
  179.     *   SSL_set_options - manipulate SSL engine options
  180.     *   Note: These are all mapped to SSL_ctrl so call them as the comment
  181.     *         specifies but know that they use SSL_ctrl.  They are #define
  182.     *         so they will map to the one in this class if called as a
  183.     *         member function of this class.
  184.     */
  185.    /* long SSL_set_options(SSL *ssl, long options); */
  186.    /*   Returns 0 if not reused, 1 if session id is reused */
  187.    /*   int SSL_session_reused(SSL *ssl); */
  188.    long    SSL_ctrl(SSL *ssl,int cmd, long larg, char *parg);
  189.  
  190.    /*
  191.     *   RAND_egd - set the path to the EGD
  192.     */
  193.    int RAND_egd(const char *path);
  194.  
  195.  
  196.    /*
  197.     *   RAND_file_name 
  198.     */
  199.    const char *RAND_file_name(char *buf, size_t num);
  200.  
  201.  
  202.    /*
  203.     *   RAND_load_file 
  204.     */
  205.    int RAND_load_file(const char *filename, long max_bytes);
  206.  
  207.  
  208.    /*
  209.     *   RAND_write_file 
  210.     */
  211.    int RAND_write_file(const char *filename);
  212.  
  213.  
  214.    /*
  215.     *   TLSv1_client_method - return a TLSv1 client method object
  216.     */
  217.    SSL_METHOD *TLSv1_client_method();
  218.  
  219.  
  220.    /*
  221.     *   SSLv2_client_method - return a SSLv2 client method object
  222.     */
  223.    SSL_METHOD *SSLv2_client_method();
  224.  
  225.  
  226.    /*
  227.     *   SSLv3_client_method - return a SSLv3 client method object
  228.     */
  229.    SSL_METHOD *SSLv3_client_method();
  230.  
  231.  
  232.    /*
  233.     *   SSLv23_client_method - return a SSLv23 client method object
  234.     */
  235.    SSL_METHOD *SSLv23_client_method();
  236.  
  237.  
  238.    /*
  239.     *   SSL_get_peer_certificate - return the peer's certificate
  240.     */
  241.    X509 *SSL_get_peer_certificate(SSL *s);
  242.  
  243.  
  244.    /*
  245.     *   SSL_get_peer_cert_chain - get the peer's certificate chain
  246.     */
  247.    STACK_OF(X509) *SSL_get_peer_cert_chain(SSL *s);
  248.  
  249.    /*
  250.     *   SSL_CIPHER_get_bits - get the number of bits in this cipher
  251.     */
  252.    int SSL_CIPHER_get_bits(SSL_CIPHER *c,int *alg_bits);
  253.  
  254.  
  255.    /*
  256.     *   SSL_CIPHER_get_version - get the version of this cipher
  257.     */
  258.    char *SSL_CIPHER_get_version(SSL_CIPHER *c);
  259.  
  260.  
  261.    /*
  262.     *   SSL_CIPHER_get_name - get the name of this cipher
  263.     */
  264.    const char *SSL_CIPHER_get_name(SSL_CIPHER *c);
  265.  
  266.  
  267.    /*
  268.     *   SSL_CIPHER_description - get the description of this cipher
  269.     */
  270.    char *SSL_CIPHER_description(SSL_CIPHER *,char *buf,int size);
  271.  
  272.  
  273.    /*
  274.     *   SSL_CTX_use_PrivateKey - set the private key for the session.
  275.     *                          - for use with client certificates
  276.     */
  277.    int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);
  278.  
  279.  
  280.    /*
  281.     *   SSL_CTX_use_certificate - set the client certificate for the session.
  282.     */
  283.    int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x);
  284.  
  285.  
  286.    /*
  287.     *   d2i_X509 - Covert a text representation of X509 to an X509 object
  288.     */
  289.    X509 * d2i_X509(X509 **a,unsigned char **pp,long length);
  290.  
  291.  
  292.    /*
  293.     *   i2d_X509 - Covert an X509 object into a text representation
  294.     */
  295.    int i2d_X509(X509 *a,unsigned char **pp);
  296.  
  297.  
  298.    /*
  299.     *   X509_cmp - compare two X509 objects
  300.     */
  301.    int X509_cmp(X509 *a, X509 *b);
  302.  
  303.  
  304.    /*
  305.     *   X509_dup - duplicate an X509 object
  306.     */
  307.    X509 *X509_dup(X509 *x509);
  308.  
  309.  
  310.    /*
  311.     *   X509_STORE_CTX_new - create an X509 store context
  312.     */
  313.    X509_STORE_CTX *X509_STORE_CTX_new(void);
  314.  
  315.  
  316.    /*
  317.     *   X509_STORE_CTX_free - free up an X509 store context
  318.     */
  319.    void X509_STORE_CTX_free(X509_STORE_CTX *v);
  320.  
  321.  
  322.    /*
  323.     *   X509_STORE_CTX_set_chain - set the certificate chain
  324.     */
  325.    void X509_STORE_CTX_set_chain(X509_STORE_CTX *v, STACK_OF(X509)* x);
  326.  
  327.    /*
  328.     *   X509_STORE_CTX_set_purpose - set the purpose of the certificate 
  329.     */
  330.    void X509_STORE_CTX_set_purpose(X509_STORE_CTX *v, int purpose);
  331.  
  332.    /*
  333.     *   X509_verify_cert - verify the certificate
  334.     */
  335.    int X509_verify_cert(X509_STORE_CTX *v);
  336.  
  337.  
  338.    /*
  339.     *   X509_STORE_new - create an X509 store
  340.     */
  341.    X509_STORE *X509_STORE_new(void);
  342.  
  343.  
  344.    /*
  345.     *   X509_STORE_free - free up an X509 store
  346.     */
  347.    void X509_STORE_free(X509_STORE *v);
  348.  
  349.  
  350.    /*
  351.     *   X509_free - free up an X509
  352.     */
  353.    void X509_free(X509 *v);
  354.  
  355.  
  356.    /*
  357.     *   X509_NAME_oneline - return the X509 data in a string
  358.     */
  359.    char *X509_NAME_oneline(X509_NAME *a, char *buf, int size);
  360.  
  361.  
  362.    /*
  363.     *   X509_get_subject_name - return the X509_NAME for the subject field
  364.     */
  365.    X509_NAME *X509_get_subject_name(X509 *a);
  366.  
  367.  
  368.    /*
  369.     *   X509_get_issuer_name - return the X509_NAME for the issuer field
  370.     */
  371.    X509_NAME *X509_get_issuer_name(X509 *a);
  372.  
  373.  
  374.    /*
  375.     *   X509_STORE_add_lookup - add a lookup file/method to an X509 store
  376.     */
  377.    X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);
  378.  
  379.  
  380.    /*
  381.     *   X509_LOOKUP_file - Definition of the LOOKUP_file method
  382.     */
  383.    X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
  384.  
  385.  
  386.    /*
  387.     *   X509_LOOKUP_free - Free an X509_LOOKUP
  388.     */
  389.    void X509_LOOKUP_free(X509_LOOKUP *x);
  390.  
  391.  
  392.    /*
  393.     *   X509_LOOKUP_ctrl - This is not normally called directly (use macros)
  394.     */
  395.    int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret);
  396.  
  397.  
  398.    /*
  399.     *   X509_STORE_CTX_init - initialize an X509 STORE context
  400.     */
  401.    void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509, STACK_OF(X509) *chain);
  402.  
  403.  
  404.    /*
  405.     *   CRYPTO_free - free up an internally allocated object
  406.     */
  407.    void CRYPTO_free(void *x);
  408.  
  409.    /*
  410.     *   BIO_new - create new BIO
  411.     */
  412.    BIO *BIO_new(BIO_METHOD *type);
  413.  
  414.    /*
  415.     *   BIO methods - only one defined here yet
  416.     */
  417.    BIO_METHOD *BIO_s_mem(void);
  418.  
  419.    /*
  420.     *   BIO_new_fp - nastiness called BIO - used to create BIO* from FILE*
  421.     */
  422.    BIO *BIO_new_fp(FILE *stream, int close_flag);
  423.  
  424.    /*
  425.     *   BIO_new_mem_buf - read only BIO from memory region
  426.     */
  427.    BIO *BIO_new_mem_buf(void *buf, int len);
  428.  
  429.    /*
  430.     *   BIO_free - nastiness called BIO - used to destroy BIO*
  431.     */
  432.    int BIO_free(BIO *a);
  433.  
  434.    /*
  435.     *   BIO_ctrl - BIO control method
  436.     */
  437.    long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
  438.  
  439.    /*
  440.     *   BIO_write - equivalent to ::write for BIO
  441.     */
  442.    int BIO_write(BIO *b, const void *data, int len);
  443.  
  444.    /*
  445.     *   PEM_write_bio_X509 - write a PEM encoded cert to a BIO*
  446.     */
  447.    int PEM_write_bio_X509(BIO *bp, X509 *x);
  448.  
  449.  
  450.    /*
  451.     *   X509_asn1_meth - used for netscape output
  452.     */
  453.    ASN1_METHOD *X509_asn1_meth();
  454.  
  455.  
  456.    /*
  457.     *   ASN1_i2d_fp - used for netscape output
  458.     */
  459.    int ASN1_i2d_fp(FILE *out, unsigned char *x);
  460.  
  461.  
  462.    /*
  463.     *   ASN1_d2i_fp - read an X509 from a DER encoded file (buf can be NULL)
  464.     */
  465.    X509 *X509_d2i_fp(FILE *out, X509** buf);
  466.  
  467.  
  468.    /*
  469.     *   X509_print - print the text form of an X509
  470.     */
  471.    int X509_print(FILE *fp, X509 *x);
  472.  
  473.  
  474.    /*
  475.     *   Read a PKCS#12 cert from fp
  476.     */
  477.    PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);
  478.  
  479.  
  480.    /*
  481.     *   Change the password on a PKCS#12 cert
  482.     */
  483.    int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass);
  484.  
  485.  
  486.    /*
  487.     *   Write a PKCS#12 to mem
  488.     */
  489.    int i2d_PKCS12(PKCS12 *p12, unsigned char **p);
  490.  
  491.  
  492.    /*
  493.     *   Write a PKCS#12 to FILE*
  494.     */
  495.    int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12);
  496.  
  497.  
  498.    /*
  499.     *   Create a new PKCS#12 object
  500.     */
  501.    PKCS12 *PKCS12_new(void);
  502.  
  503.  
  504.    /*
  505.     *   Destroy that PKCS#12 that you created!
  506.     */
  507.    void PKCS12_free(PKCS12 *a);
  508.  
  509.  
  510.    /* 
  511.     *   Parse the PKCS#12 
  512.     */
  513.    int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey,
  514.                     X509 **cert, STACK_OF(X509) **ca);
  515.  
  516.  
  517.    /* 
  518.     *   Free the Private Key
  519.     */
  520.    void EVP_PKEY_free(EVP_PKEY *x);
  521.  
  522.  
  523.    /* 
  524.     *   Pop off the stack
  525.     */
  526.    char *sk_pop(STACK *s);
  527.  
  528.  
  529.    /* 
  530.     *   Free the stack
  531.     */
  532.    void sk_free(STACK *s);
  533.  
  534.  
  535.    /* 
  536.     *  Number of elements in the stack
  537.     */
  538.    int sk_num(STACK *s);
  539.  
  540.  
  541.    /* 
  542.     *  Value of element n in the stack
  543.     */
  544.    char *sk_value(STACK *s, int n);
  545.  
  546.  
  547.    /* 
  548.     *  Create a new stack
  549.     */
  550.    STACK *sk_new(int (*cmp)());
  551.  
  552.  
  553.    /* 
  554.     *  Add an element to the stack
  555.     */
  556.    int sk_push(STACK *s, char *d);
  557.  
  558.  
  559.    /* 
  560.     *  Duplicate the stack
  561.     */
  562.    STACK *sk_dup(STACK *s);
  563.  
  564.  
  565.    /*
  566.     *  Convert an ASN1_INTEGER to it's text form
  567.     */
  568.    char *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint);
  569.  
  570.  
  571.    /*
  572.     *  Get the certificate's serial number
  573.     */
  574.    ASN1_INTEGER *X509_get_serialNumber(X509 *x);
  575.  
  576.  
  577.    /*
  578.     *  Get the certificate's public key
  579.     */
  580.    EVP_PKEY *X509_get_pubkey(X509 *x);
  581.  
  582.  
  583.    /*
  584.     *  Convert the public key to a decimal form
  585.     */
  586.    int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp); 
  587.  
  588.  
  589.    /*
  590.     *  Check the private key of a PKCS bundle against the X509
  591.     */
  592.    int X509_check_private_key(X509 *x, EVP_PKEY *p);
  593.  
  594.  
  595.    /*
  596.     *  Convert a BIGNUM to a hex string
  597.     */
  598.    char *BN_bn2hex(const BIGNUM *a);
  599.  
  600.  
  601.    /*
  602.     *  Compute the digest of an X.509
  603.     */
  604.    int X509_digest(const X509 *x,const EVP_MD *t, unsigned char *md, unsigned int *len);
  605.  
  606.  
  607.    /*
  608.     *  EVP_md5
  609.     */
  610.    EVP_MD *EVP_md5();
  611.  
  612.  
  613.    /*
  614.     *  ASN1_INTEGER free
  615.     */
  616.    void ASN1_INTEGER_free(ASN1_INTEGER *x);
  617.  
  618.  
  619.    /*
  620.     *  ASN1_STRING_data
  621.     */
  622.    unsigned char *ASN1_STRING_data(ASN1_STRING *x);
  623.  
  624.    /*
  625.     *  
  626.     */
  627.    int OBJ_obj2nid(ASN1_OBJECT *o);
  628.  
  629.    /*
  630.     *  
  631.     */
  632.    const char * OBJ_nid2ln(int n);
  633.  
  634.    /*
  635.     * get the number of extensions
  636.     */
  637.    int X509_get_ext_count(X509 *x);
  638.  
  639.    /*
  640.     * 
  641.     */
  642.    int X509_get_ext_by_NID(X509 *x, int nid, int lastpos);
  643.  
  644.    /*
  645.     *
  646.     */
  647.    int X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos);
  648.  
  649.    /*
  650.     *
  651.     */
  652.    X509_EXTENSION *X509_get_ext(X509 *x, int loc);
  653.  
  654.    /*
  655.     *
  656.     */
  657.    X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
  658.  
  659.    /*
  660.     *
  661.     */
  662.    int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
  663.  
  664.    /*
  665.     *
  666.     */
  667.    void *X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);
  668.  
  669.    /*
  670.     *
  671.     */
  672.    char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5);
  673.  
  674.    /*
  675.     *
  676.     */
  677.    int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
  678.  
  679.    /*
  680.     *
  681.     */
  682.    PKCS7 *PKCS7_new(void);
  683.  
  684.    /*
  685.     *
  686.     */
  687.    void PKCS7_free(PKCS7 *a);
  688.  
  689.    /*
  690.     *
  691.     */
  692.    void PKCS7_content_free(PKCS7 *a);
  693.  
  694.    /*
  695.     *
  696.     */
  697.    int i2d_PKCS7(PKCS7 *a, unsigned char **pp);
  698.  
  699.    /*
  700.     *
  701.     */
  702.    PKCS7 *d2i_PKCS7(PKCS7 **a, unsigned char **pp,long length);
  703.  
  704.    /*
  705.     *
  706.     */
  707.    int i2d_PKCS7_fp(FILE *fp,PKCS7 *p7);
  708.  
  709.    /*
  710.     * 
  711.     */
  712.    PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7);
  713.  
  714.    /*
  715.     *
  716.     */
  717.    int i2d_PKCS7_bio(BIO *bp,PKCS7 *p7);
  718.  
  719.    /*
  720.     *
  721.     */
  722.    PKCS7 *d2i_PKCS7_bio(BIO *bp,PKCS7 **p7);
  723.  
  724.    /*
  725.     *
  726.     */
  727.    PKCS7 *PKCS7_dup(PKCS7 *p7);
  728.  
  729.    /*
  730.     *  Create a PKCS7 signature / signed message
  731.     */
  732.    PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
  733.              BIO *data, int flags);
  734.  
  735.    /*
  736.     *  Verify a PKCS7 signature.
  737.     */
  738.    int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
  739.                                               BIO *indata, BIO *out, int flags);
  740.  
  741.    /*
  742.     *  Get signers of a verified PKCS7 signature
  743.     */
  744.    STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags);
  745.  
  746.    /*
  747.     *  PKCS7 encrypt message
  748.     */
  749.    PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, EVP_CIPHER *cipher,
  750.             int flags);
  751.  
  752.    /*
  753.     *  decrypt PKCS7 message
  754.     */
  755.    int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags);
  756.  
  757.  
  758.    /*
  759.     * Load a CA list file.
  760.     */
  761.    STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);
  762.  
  763.    /*
  764.     * Load a file of PEM encoded objects.
  765.     */
  766.    STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
  767.                    pem_password_cb *cb, void *u);
  768.  
  769.    /*
  770.     * Get the number of purposes available
  771.     */
  772.    int X509_PURPOSE_get_count();
  773.  
  774.  
  775.    /*
  776.     * Get the ID of a purpose
  777.     */
  778.    int X509_PURPOSE_get_id(X509_PURPOSE *);
  779.  
  780.  
  781.    /*
  782.     * Check the existence of purpose id "id" in x.  for CA, set ca = 1, else 0
  783.     */
  784.    int X509_check_purpose(X509 *x, int id, int ca);
  785.  
  786.  
  787.    /*
  788.     * Get the purpose with index #idx
  789.     */
  790.    X509_PURPOSE * X509_PURPOSE_get0(int idx);
  791.  
  792.  
  793.    /*
  794.     * Create a new Private KEY
  795.     */
  796.    EVP_PKEY* EVP_PKEY_new();
  797.  
  798.  
  799.    /*
  800.     * Assign a private key
  801.     */
  802.    int EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key);
  803.  
  804.  
  805.    /*
  806.     * Generate a RSA key
  807.     */
  808.    RSA *RSA_generate_key(int bits, unsigned long e, void
  809.                         (*callback)(int,int,void *), void *cb_arg);
  810.  
  811.  
  812.    /*
  813.     * Create/destroy a certificate request
  814.     */
  815.    X509_REQ *X509_REQ_new();
  816.    void X509_REQ_free(X509_REQ *a);
  817.  
  818.  
  819.    /*
  820.     * Set the public key in the REQ object
  821.     */
  822.    int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
  823.  
  824.    /* for testing */
  825.    int i2d_X509_REQ_fp(FILE *fp, X509_REQ *x);
  826.  
  827.    /* SMime support */
  828.    STACK *X509_get1_email(X509 *x);
  829.    void X509_email_free(STACK *sk);
  830.  
  831.    /* Ciphers needed for SMime */
  832.    EVP_CIPHER *EVP_des_ede3_cbc();
  833.    EVP_CIPHER *EVP_des_cbc();
  834.    EVP_CIPHER *EVP_rc2_cbc();
  835.    EVP_CIPHER *EVP_rc2_64_cbc();
  836.    EVP_CIPHER *EVP_rc2_40_cbc();
  837.  
  838.    /* clear the current error  - use this often*/
  839.    void ERR_clear_error();
  840.  
  841.    /* retrieve the latest error */
  842.    unsigned long ERR_get_error();
  843.  
  844.    /* Print the errors to this stream */
  845.    void ERR_print_errors_fp(FILE *fp);
  846.  
  847.    /* Get a pointer to the SSL session id (reference counted) */
  848.    SSL_SESSION *SSL_get1_session(SSL *ssl);
  849.  
  850.    /* Frees a pointer to the SSL session id (reference decremented if needed) */
  851.    void SSL_SESSION_free(SSL_SESSION *session);
  852.  
  853.    /* Set the SSL session to reuse. */
  854.    int SSL_set_session(SSL *ssl, SSL_SESSION *session);
  855.  
  856.    /* Decode ASN.1 to SSL_SESSION */
  857.    SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, unsigned char **pp, long length);
  858.    /* Encode SSL_SESSION to ASN.1 */
  859.    int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);
  860.  
  861.    /* Write privatekey to FILE stream */
  862.    int i2d_PrivateKey_fp(FILE*, EVP_PKEY*);
  863.  
  864.    /* Write PKCS#8privatekey to FILE stream */
  865.    int i2d_PKCS8PrivateKey_fp(FILE*, EVP_PKEY*, const EVP_CIPHER*, char*, int, pem_password_cb*, void*);
  866.  
  867.    /* Free RSA structure */
  868.    void RSA_free(RSA*);
  869.  
  870.    /* Get a blowfish CBC pointer */
  871.    EVP_CIPHER *EVP_bf_cbc();
  872.  
  873.    /* Sign a CSR */
  874.    int X509_REQ_sign(X509_REQ*, EVP_PKEY*, const EVP_MD*);
  875.  
  876.    /* add a name entry */
  877.    int X509_NAME_add_entry_by_txt(X509_NAME*, char*, int, unsigned char*, int, int, int);
  878.  
  879.    /* Create a name */
  880.    X509_NAME *X509_NAME_new();
  881.  
  882.    /* Set the subject */
  883.    int X509_REQ_set_subject_name(X509_REQ*,X509_NAME*);
  884.  
  885.    /* get list of available SSL_CIPHER's sorted by preference */
  886.    STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL* ssl);
  887.  
  888. #endif
  889.  
  890. private:
  891.    KOpenSSLProxy();
  892.    ~KOpenSSLProxy();
  893.    KOpenSSLProxyPrivate *d;
  894.  
  895.    KLibrary *_sslLib;
  896.    KLibrary *_cryptoLib;
  897.    static KOpenSSLProxy *_me;
  898.  
  899.    bool _ok;
  900. };
  901.  
  902. #endif
  903.  
  904.